export default {
    install(Vue) {

        // 跳转url,并且指定面包屑
        Vue.prototype.showFullPageLoading = function () {
            this.$Spin.show({
                render: (h) => {
                    return h('div', [
                        h('Icon', {
                            'class': 'demo-spin-icon-load',
                            props: {
                                type: 'ios-loading',
                                size: 25
                            }
                        }),
                        h('div', '拼命加载中...')
                    ]);
                }
            });
            this.$Loading.config({
                color: '#515A6E',
                failedColor: '#f0ad4e',
            });
            this.$Loading.start();
        };
        Vue.prototype.hideFullLoading = function () {
            this.$Spin.hide();
            this.$Loading.finish();
        };


        /**
         * 商品管理菜单跳转
         * @param str
         */
        Vue.prototype.jumpMenu = function (str) {
            switch (str) {
                case '客户管理':
                    this.pushUrl('/custom');
                    break;
                case '课程管理':
                    this.pushUrl('/class');
                    break;
                case '教练管理':
                    this.pushUrl('/coach');
                    break;
            }
        };

        // 返回选中的菜单名称
        Vue.prototype.getSelectMenuName = function () {
            var queryTitle = this.$route.query.title;
            if (this.strError(queryTitle)) {
                return this.$route.name;
            }
            console.log('菜单名称:' + queryTitle);
            return queryTitle;
        };

        // 刷新菜单名称
        Vue.prototype.refreshMenuName = function () {
            var name = this.getSelectMenuName();
            this.saveMenuName(name);
        };

        // 跳转url,并且指定面包屑
        Vue.prototype.pushUrl = function (url, query) {
            this.$router.push({
                path: url,
                query: query
            });
        };
    }
};
